/*
 * @Date         : 2022-09-08 09:12:21
 * @LastEditTime : 2023-02-16 11:25:24
 * @LastEditors  : Please set LastEditors
 * @Description  :  
 * @FilePath     : \BlueOraAimV2_0\User\Application\myQueue.h
 * @FileLog      :  
 */
#ifndef MYQUEUE_H
#define MYQUEUE_H


#include "stdio.h"
#include "stdlib.h"
#include "sys.h"

#define BYTE    u8 
#define BOOL    u8 
#define TRUE    1 
#define FALSE   0 
		
typedef u8 QElementType;

/* 声明队列数据类型结构体 */
typedef struct{
  u8 mcode;
  struct {
    u16 regAddr;
    u8 regNum;
  }reg[10];
  u8 ptrNum;
}queueType;

#define QUEUE_SIZE 10

void my_queue_init(void);

void my_queue_enqueue(u8 mcode, u16 regAddr0, u8 regNum0,
                      u16 regAddr1, u8 regNum1,
                      u16 regAddr2, u8 regNum2,
                      u16 regAddr3, u8 regNum3,
                      u16 regAddr4, u8 regNum4,
                      u16 regAddr5, u8 regNum5,
                      u16 regAddr6, u8 regNum6,
                      u16 regAddr7, u8 regNum7,
                      u16 regAddr8, u8 regNum8,
                      u16 regAddr9, u8 regNum9,
                      u8 ptrNum);
void my_queue_dequeue(void);
/**
 * In order to use the Queue module, a variable of this type must be declared before calling
 * \ref ZW_util_queue_Init.
 */
typedef struct
{
  u8 out;
  u8 in;
  u8 count;
  u8 queueSize;
  u8 elementType;
  QElementType* array;
}
QUEUE_T;

/**
 * @brief Initializes a given queue with a given buffer.
 * @param[in] pQueue Pointer to the queue to initialize.
 * @param[in] pBuffer Pointer to a buffer to initialize the queue with.
 * @param[in] sizeOfElements Size of elements in the given buffer.
 * @param[in] numberOfElements Number of elements in the given buffer.
 */
void queue_Init(QUEUE_T * pQueue, void * pBuffer, BYTE sizeOfElements, BYTE numberOfElements);

/**
 * @brief Enqueues a given element to a given queue.
 * @param[in] pQueue Pointer to a queue.
 * @param[in] pElement Pointer to an element.
 * @return TRUE if element was enqueued, FALSE otherwise.
 */
BOOL queue_Enqueue(QUEUE_T * pQueue, void * pElement);

/**
 * @brief Dequeues a given element from a given queue.
 * @param[in] pQueue Pointer to a queue.
 * @param[out] pElement Pointer to an element.
 * @return TRUE if element was dequeued, FALSE otherwise.
 */
BOOL queue_Dequeue(QUEUE_T * pQueue, void * pElement);

/**
 * @brief Get number of elements in queue.
 * @param[in] pQueue Pointer to a queue.
 * @return Number of queue elements.
 */
u8 queue_GetItemCount(QUEUE_T * pQueue);

#endif

